package test1225;

public class Test12 {
    public static void main(String[] args) {
        // 返回arr与brr的差集
        int[] arr = {1,2,3,4,5};
        int[] brr = {3,4,5,6,7};
        int[] crr = m12(arr, brr);
        for (int c:crr) {
            System.out.println(c);
        }
    }
    public static int[] m12(int[] arr, int[] brr){
        int[] middle = new int[arr.length+brr.length];
        int jiao = 0;
        for(int i = 0;i<arr.length;i++){
            boolean kaiguan = false;
            for(int j = 0;j<brr.length;j++){
                if(arr[i]==brr[j]){
                    kaiguan = true;
                    break;
                }
            }
            if(!kaiguan){
                middle[jiao] = arr[i];
                jiao++;
            }
        }
        for(int i = 0;i<brr.length;i++){
            boolean kaiguan = false;
            for(int j = 0;j<arr.length;j++){
                if(brr[i]==arr[j]){
                    kaiguan = true;
                    break;
                }
            }
            if(!kaiguan){
                middle[jiao] = brr[i];
                jiao++;
            }
        }
        int[] finalArr = new int[jiao];
        for(int i = 0;i<jiao;i++){
            finalArr[i] = middle[i];
        }
        return finalArr;
    }
}